import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluwx_no_pay/fluwx_no_pay.dart';
// import 'package:fluwx/fluwx.dart';
import 'package:get/get.dart';
import '../../base/get/get_extension.dart';
import '../../res/button_style.dart';
import '../../res/colors.dart';
import '../../res/r.dart';
import '../../res/style.dart';

import '../../res/strings.dart';
import 'dialog_base.dart';

class ShareDislog extends StatelessWidget {
  String url = 'https://www.baidu.com';
  String title = '';
  String imgStr = '';

  ShareDislog({
    Key? key,
    this.url = 'https://www.baidu.com',
    this.title = '',
    this.imgStr = '',

  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return BaseDialog(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Box.vBox30,
            Text(
              "分享",
              style: Styles.style_black_16,
            ),
            Box.vBox5,
            Padding(
              padding: const EdgeInsets.all(15.0).r,
              child: Text(
                title,
                style: Styles.style_B8C0D4_14,
              ),
            ),
            Box.vBox10,
            GestureDetector(
              onTap: () async {
                var model = WeChatShareMiniProgramModel(
                    webPageUrl: imgStr,
                    userName: 'gh_9d4592c0c125',
                    description: "津房置换",
                    thumbnail: WeChatImage.network(imgStr),
                    path: url,
                    title: title);

                shareToWeChat(model);

                Get.back();
                // payWithWeChat(appId: "wx8888888888888888",
                //     partnerId: "1900000109",
                //     prepayId: "WX1217752501201407033233368018",
                //     packageValue: "Sign=WXPay",
                //     nonceStr: "5K8264ILTKCH16CQ2502SI8ZNMTM67VS",
                //     timeStamp: 1412000000,
                //     sign: "oR9d8PuhnIc+YZ8cBHFCwfgpaK9gd7vaRvkYD7rthRAZ\/X+QBhcCYL21N7cHCTUxbQ+EAt6Uy+lwSN22f5YZvI45MLko8Pfso0jm46v5hqcVwrk6uddkGuT+Cdvu4WBqDzaDjnNa5UK3GfE1Wfl2gHxIIY5lLdUgWFts17D4WuolLLkiFZV+JSHMvH7eaLdT9N5GBovBwu5yYKUR7skR8Fu+LozcSqQixnlEZUfyE55feLOQTUYzLmR9pNtPbPsu6WVhbNHMS3Ss2+AehHvz+n64GDmXxbX++IOBvm2olHu3PsOUGRwhudhVf7UcGcunXt8cqNjKNqZLhLw4jq\/xDg==");
              },
              behavior: HitTestBehavior.opaque,
              child: Column(
                children: [
                  Image.asset(
                    R.shareWechat,
                    width: 50.w,
                    height: 50.h,
                  ),
                  const Text(
                    '微信好友',
                    style: TextStyle(color: Colors.grey, fontSize: 13),
                  )
                ],
              ),
            ),
            Box.vBox20,
            // Row(
            //   mainAxisAlignment: MainAxisAlignment.spaceAround,
            //   children: [
            //     // 浏览器打开
            //     // _buildShareIcon(ColorStyle.color_24CF5F, Icons.public,
            //     //         () => Navigate.lauchInBrower(url)),
            //
            //     // 保存在本地
            //     _buildShareIcon(ColorStyle.color_FE8C28, Icons.download, () {
            //       PermissionRequest.sendPermission((value) {
            //         if (value) {
            //           FileUtils.saveAssetsGallery(assets: R.assetsShareQRCode);
            //         }
            //       });
            //     }),
            //   ],
            // ),
            // Box.vBox5,
            // Row(
            //   mainAxisAlignment: MainAxisAlignment.spaceAround,
            //   children: [
            //     // 在浏览器打开
            //     Text(
            //       StringStyles.shareBrowser.tr,
            //       style: Styles.style_B8C0D4_13,
            //     ),
            //     // 保存在本地
            //     Text(
            //       StringStyles.shareSaveLocal.tr,
            //       style: Styles.style_B8C0D4_13,
            //     ),
            //   ],
            // ),
            // Box.vBox30,
            DividerStyle.divider1Half,
            SizedBox(
              width: double.infinity,
              height: 60.h,
              child: TextButton(
                  style: ButtonStyles.getNoShapeStyle(),
                  onPressed: () {
                    Get.dismiss();
                  },
                  child: Text(
                    StringStyles.quit.tr,
                    style: Styles.style_B8C0D4_13,
                  )),
            ),
          ],
        ));
  }

  Widget _buildShareIcon(Color color, IconData icon, VoidCallback onTap) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        padding: const EdgeInsets.all(8).r,
        decoration: const BoxDecoration(
            color: ColorStyle.colorShadow,
            borderRadius: BorderRadius.all(Radius.circular(30))),
        child: Icon(
          icon,
          color: color,
          size: 30.r,
        ),
      ),
    );
  }
}
